﻿$(document).ready(function(){

var page_url = location.href;
if (page_url.match(/^.+\/entrylist[\-0-9]*\.html$/g )) {
var entries = $(".newentrytitle a");
var classname = ".updatetime";
var flg = 0;
} else {
var entries = $(".foot a:contains('記事URL')");
var classname = "div.foot";
var flg = 1;
}
for (i = 0; i < entries.length; i++) {
var url = entries[i];
if (flg == 0) {
title = entries.eq(i).text();
} else {
title = $("div.entry h3.title").eq(i).text();
}

    var hatena_btn, twitter_btn, tumblr_btn, ameba_btn, mixi_btn, gplus_btn, facebook_btn;
 
    if (/Firefox/i.test(navigator.userAgent)) {
    tumblr_btn = '<a href="http://www.tumblr.com/share?v=3&u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title + '"|Nammie&quot;s Drive, Rail, Entertainment, and Music"') + '" ' +
                 'title="Share on Tumblr" ' +
                 'style="display:inline-block; overflow:hidden; width:61px; height:20px; ' +
                 'background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;" ' +
                 'data-text="' + title + '"|Nammie&quot;s Drive, Rail, Entertainment, and Music"' + '" data-url="' + url + '"></a>';
    } else {
    tumblr_btn = '<a href="http://www.tumblr.com/share" title="Share on Tumblr" ' +
                 'style="display:inline-block; overflow:hidden; width:61px; height:20px; ' +
                 'background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;" ' +
                 'data-text="' + title + '"|Nammie&quot;s Drive, Rail, Entertainment, and Music"' + '" data-url="' + url + '"></a>';
    }
    ameba_btn = '<a rel="nofollow" target="_blank" href="http://stat100.ameba.jp/blog/proxy.html?longurl=' + url + '&title=' + title + '&type=now">' +
                '<img src="http://stat100.ameba.jp/common_style/img/common/btn/btn_share_now.gif" alt="なうで紹介"></a>';
    mixi_btn = '<a rel="nofollow" target="_blank" href="http://stat100.ameba.jp/blog/proxy.html?longurl=' + url + '&type=mixi">' +
               '<img src="http://stat100.ameba.jp/common_style/img/common/btn/btn_share_mixi.png" alt="mixiチェック"></a>';
    gplus_btn = '<div class="g-plusone" size="medium" data-size="medium" data-count="true" href=' + url + '></div>';
    facebook_btn = '<iframe src="http://www.facebook.com/plugins/like.php?href='+ encodeURIComponent(url) +
                   '&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light&height=21" scrolling="no" ' +
                   'frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe> ';
    hatena_btn = '<a href="' + url + '" class="hatena-bookmark-button" data-hatena-bookmark-title="' +
                 title + '" data-hatena-bookmark-layout="standard" title="このエントリーをはてなブックマークに追加">' +
                 '<img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>';
    twitter_btn = '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="nammie8848" data-text="' +
                  title + '"|Nammie&quot;s Drive, Rail, Entertainment, and Music"' + '" data-url="' + url + '">Tweet</a>';

$(classname).eq(i).before('&nbsp;&nbsp;&nbsp;' + ' <span>' + hatena_btn + '</span>' + '&nbsp;' + ' <span>' + twitter_btn + '</span>' + '&nbsp;' + ' <span>' + tumblr_btn + '</span>' + '&nbsp;' + ' <span>' + ameba_btn + '</span>' + '&nbsp;' + ' <span>' + mixi_btn + '</span>' + '&nbsp;' + ' <span>' + facebook_btn + '</span>' );
}
})
